﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QDT.P2B.Activity
{
    public class PrizeBuilder
    {

        private static readonly List<ushort> Weights = new List<ushort>(
            new ushort[]{
            2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,3,3,3,3,3,
            4,4,4,4,4,4,4,4,4,4,
            4,4,4,4,4,4,4,4,4,4,
            5,5,5,5,5,5,5,5,5,5,
            5,5,5,5,5,5,5,5,5,5
        });


        private static int Random()
        {
            var ra = new Random().Next(99);
            var time = DateTime.Now.Millisecond;
            var item = (time*ra) % 99;
            return Weights[item];
        }


        public Prize Prize()
        {
            var i = Random();
            switch (i)
            {
                case 1:
                    return new Prize { Id = i, Name = "5元话费" };
                case 2:
                    return new Prize { Id = i, Name = "10元话费" };
                case 3:
                    return new Prize { Id = i, Name = "50元话费" };
                case 4:
                    return new Prize { Id = i, Name = "30元红包" };
                case 5:
                    return new Prize { Id = i, Name = "40元红包" };
                default:
                    return null;
            }
        }

    }
}
